<?php
class MD_Media
{
	public static function getAll()
	{
		$content = TN_Db::getInstance()->fetchAll("SELECT * FROM multimedia ");
    	return $content;
	}
	
	public static function getMediaById($id)
	{
		$content = TN_Db::getInstance()->fetchAll("SELECT * FROM multimedia where id = '$id' ");
    	return $content[0];
	} 

	public static function add( $name, $descripcion, $file )
	{
		TN_Db::getInstance()->insert('multimedia', array('name'=> $name, 'description' => $descripcion, 'file' => $image));
	}
	
	public static function update($id, $name, $descripcion, $file)
	{
		TN_Db::getInstance()->update('multimedia', array('name'=> $name, 'description' => $descripcion,'file' => $file ), "id = '$id' ");
	}
		
	public static function delete ($id )
	{
		TN_Db::getInstance()->delete('multimedia', "id = '$id' ");
	}
 	public static function lastId()
    {
    	return TN_Db::getInstance()->lastInsertId('multimedia');
    }
    
    public static function setImage($id, $img)
    {
    	TN_Db::getInstance()->update('multimedia', array('file' => $img), "id = '$id' ");
    }
}
?>